;; Sri Ganeshji : Sri Balaji : Sri Pitreshwarji : Sri Durgaji : Sri Venkateshwara

/*
Objective(s) -
-	This code demonstrates the concept of Multi Column Reports using Trial Balance

Last modification -
-	Altered on 09-11-2009
*/

[Report: MulCol Trial Balance]

;;	Title		: $$LocaleString:"Trial Balance"
	Form		: MulCol Trial Balance


	Repeat      : SVCurrentCompany, SVFromDate, SVToDate
	ColumnReport: MyMultiColumns

	Variable	: MulCol TB Group, IsLedgerWise

    PrintSet    : Report Title      : $$LocaleString:"Trial Balance"
    Set         : IsLedgerWise      : No

/* When the attribute Column Report is mentioned, the attribute 
 Repeat should also be mentioned. The New Column, Alter Column and 
 Delete Column buttons will automatically get activated 
 once Column Report & Repeat attributes are mentioned 
 together in the report.

 PrintSet At Report Definition will set the Variable Value
 in Print Mode */

[Form: MulCol Trial Balance]
    
    Button      : F2ChangePeriod, ChangeCompany, LedgerWiseButton
	Keys        : ChangePeriod
;;To incorporate the change in TallyPrime
	Bottom Button	: Add Column, Alter Column, Delete Column

	BottomButton: InvReports, AcctReports, ReportOperations, FilterButton, ValueButton
	Buttons		: PrintButton, ExportButton, UploadButton, MailButton
	Parts		: MulCol TB Title, MulCol TB Details
	Height		: 100% Page
	Width		: 100% Page
	Space Top	: 0
	Space Left	: 0
	Background	: Released Pale Yellow
	Option		: Prn MulCol TB		: $$InPrintMode
	
	[!Form: Prn MulCol TB]
	
		Delete		: Parts		: MulCol TB Title
        Add         : Parts     : At Beginning  : MulCol TB OpPgPart
   		Space Left	: 0.25 inch
   		
;; For enabling Titles during Printing, Form Level Optional parts 
;; Company Name, Address and Report Title are used from defTDL.
       
    [Part: MulCol TB OpPgPart]
    
        Parts       : DSP CompanyName, DSP CompanyAddress, MulCol TB Title
        Vertical    : Yes

;; Every continuous page should have the above parts during Printing

	[Part: MulCol TB Title]

		Lines		: MulCol TB Title1, MulCol TB Title2, MulCol TB Title3, MulCol TB STitle
		Border      : Thin Top

		[Line: MulCol TB Title1]

			Use			: MulCol TB Title3
			Local		: Field		: Name Field		    : Set as		: ""
			Local		: Field		: MulCol TB DrAmt Field	: Set as		: @@CmpMailName
			Local		: Field		: MulCol TB DrAmt Field	: Lines			: 0
			Local		: Field		: MulCol TB DrAmt Field	: Border		: Thin Left
			Invisible   : $$IsCommon:SVCurrentCompany AND $$InPrintMode
			
;; This Line is made Invisible in Print Mode only if Columns selected
;; are of single company

		[Line: MulCol TB Title2]

			Use			: MulCol TB Title3
			Local		: Field		: Default		    	: Style			: Normal
			Local		: Field		: Name Field		    : Set as		: $$LocaleString:"Particulars"
			Local		: Field		: Name Field		    : Style			: Normal Bold
			Local		: Field		: Name Field	    	: WideSpaced	: Yes
			Local		: Field		: MulCol TB DrAmt Field	: Set as		: @@DSPDateStr
			Local		: Field		: MulCol TB DrAmt Field	: Border		: Left Full Thin Bottom
			
;; DSPFDateStr is the Default Formula which displays the values 
;; present in both the date variables - SVFromDate & SVTodate 

		[Line: MulCol TB Title3]

			Fields		: Name Field, MulCol TB DrAmt Field
			Local		: Field		: Default			    : Type			: String
			Local		: Field		: Name Field		    : Set as		: ""
			Local		: Field		: Name Field		    : Align			: Center
			Local		: Field		: MulCol TB DrAmt Field	: Align			: Centre
			Local		: Field		: MulCol TB DrAmt Field	: Border		: Left Full Thin Bottom
			Local		: Field		: MulCol TB DrAmt Field	: Set as		: $$LocaleString:"Closing Balance"
			Repeat		: MulCol TB DrAmt Field

		[Line: MulCol TB STitle]

			Fields		: Name Field, MulCol TB Amount Field
			Local		: Field		: Default			    : Style			: Normal
			Local		: Field		: Default			    : Align			: Centre
			Local		: Field		: Default			    : Type			: String
			Local		: Field		: Name Field		    : Set as		: ""
			Local		: Field		: MulCol TB DrAmt Field	: Set as		: $$LocaleString:"Debit"
			Local		: Field		: MulCol TB CrAmt Field	: Set as		: $$LocaleString:"Credit"
			Local		: Field		: MulCol TB CrAmt Field	: Border		: Thin Left
			Repeat		: MulCol TB Amount Field
			Border		: Thin Bottom
			
	[Part: MulCol TB Details]

		Lines		: MulCol TB Details
		BottomLines	: MulCol TB Total
		Repeat		: MulCol TB Details	: MulCol TB GroupLed
		Total		: MulCol TB DrAmt Field, MulCol TB CrAmt Field
		Scroll		: Vertical
		CommonBorder: Yes
		Float		: Yes
	    Option      : MulCol TB Details Led : ##IsLedgerWise
  
;; The optional part is selected when Ledgerwise is selected by the user.
        
        [!Part: MulCol TB Details Led]

		    Repeat		: MulCol TB Details	: MulCol TB Led
		    Local       : Collection: MulCol TB Led         : BelongsTo     : Yes

;; If Ledgerwise Option is selected by the user, Collection should
;; have attribute BelongsTo set to Yes as the Ledgers pertaining to
;; all the Groups and Sub-Groups needs to be displayed together
		    
	[Line: MulCol TB Details]

			Fields		: MulCol TB Name Field, MulCol TB Amount Field
			Local		: Field		: MulCol TB Name Field	: Set as		: $$Name
			Local		: Field		: MulCol TB DrAmt Field	: Set as		: if $$IsDr:$ClosingBalance then $ClosingBalance else 0
			Local		: Field		: MulCol TB CrAmt Field	: Set as		: if $$IsDr:$ClosingBalance then 0 else $ClosingBalance
			Repeat		: MulCol TB Amount Field

;; Repeat Attribute of Line will position the Field to the Right, 
;; as if it is a Right Field.
	
			[Field: MulCol TB Name Field]

				Use			: Name Field
				Variable	: MulCol TB Group
				Display		: MulCol Trial Balance		: $$IsGroup
				Option		: MulCol TB LedName Field	: $$IsLedger

				[!Field: MulCol TB LedName Field]

					Variable	: LedgerName
					Display		: Ledger Monthly Summary
					Style       : Normal Italic

			[Field: MulCol TB Amount Field]

				Fields		: MulCol TB DrAmt Field, MulCol TB CrAmt Field
				Border		: Thin Left
				Display		: MulCol Trial Balance		: $$IsGroup
				Display		: Ledger Monthly Summary    : $$IsLedger
				    			    
				[Field: MulCol TB DrAmt Field]

					Use			: Amount Field
					Style       : Normal

				[Field: MulCol TB CrAmt Field]

					Use			: Amount Field
					Style       : Normal

			[Collection: MulCol TB GroupLed]
			
				Collection	: MulCol TB Group, MulCol TB Led
                			
			[Collection: MulCol TB Group]
			
				Type		: Group
				Child Of	: ##MulColTBGroup
				Filter		: NoProfit
				Fetch		: Name, ClosingBalance
				
;; NoProfit Formula is used to Filter all the Ledgers
;; except Profit and Loss Account.
			
			[Collection: MulCol TB Led]
			
				Type		: Ledger
				Child Of	: ##MulColTBGroup
				Filter		: NoProfit
				Fetch		: Name, ClosingBalance

			[Variable: MulCol TB Group]
			
				Type		: String
				Default     : ""
				Volatile	: Yes
	
;;			[System: Formula]
;;
;;				NoProfit	: NOT $$IsLedgerProfit AND $ClosingBalance > 0

;; Function IsLedgerProfit returns Yes, only if the current object
;; is a Profit & Loss Ledger Account.

    	[Line: MulCol TB Total]

			Use			: MulCol TB Details
			Local       : Field     : Default               : Style         : Normal Bold
			Local		: Field		: MulCol TB Name Field	: Set as		: "GRAND TOTAL"
			Local       : Field     : MulCol TB Name Field	: WideSpaced    : Yes
			Local		: Field		: MulCol TB Name Field	: Align			: Centre
			Local		: Field		: MulCol TB DrAmt Field	: Set as		: $$Total:MulColTBDrAmtField
			Local		: Field		: MulCol TB CrAmt Field	: Set as		: $$Total:MulColTBCrAmtField
			Border		: Flush Totals
			Fixed		: Yes
			Space Top   : 1

;; Fixed Attribute at Line Definition will not allow the cursor to be
;; placed on that line while viewing and scrolling

;; End-of-Trial-Balance

;; Report for displaying Column Option

[Report: MyMultiColumns]

    Title       : $$LocaleString:"Column Details"

[Form: MyMultiColumns]

    No Confirm  : Yes
    Full Width  : No

    Space Right : 0.25
    Background  : @@SV_UNBLUE
    Parts       : My MultiColumns
    Option      : Small Size Form

[Part: My MultiColumns]

    Lines       : Form SubTitle, My MultiCompany, My MultiFromDate, My MultiToDate
    Local       : Field : Form SubTitle     : Info      : $$LocaleString:"Column Details"

    [Line: My MultiCompany]

		Fields      : Short Prompt, My MultiCompany
        Local       : Field : Short Prompt 	: Info 		: $$LocaleString:"Company :"
        SpaceBottom : 1
        Invisible   : $$SelectedCmps = 1

;; SelectedCmps is a function which returns the number of selected companies.  
;; It requires no parameters.  This means that if the Selected Companies equals
;; to 1 then this line should be made invisible

        [Field: My MultiCompany]

            Use         : Name Field
            Modifies    : SVCurrentCompany
            Table       : Company
            Show Table  : Always

;; Modifies alters the Value of a Variable to be used subsequently
            
    [Line: My MultiFromDate]

		Fields      : Short Prompt, My MultiFromDate
        Local       : Field : Short Prompt 	: Info 		: $$LocaleString:"From Date :"
        SpaceBottom : 1

        [Field: My MultiFromDate]

            Use         : Uni Date Field
            Modifies    : SVFromDate
            Width       : 9

    [Line: My MultiToDate]

		Fields      : Short Prompt, My MultiToDate
        Local       : Field : Short Prompt 	: Info 		: $$LocaleString:"To Date :"
        SpaceBottom : 0.25
        
        [Field: My MultiToDate]

            Use         : My MultiFromDate
            Modifies    : SVToDate
            
;; End-of-File
